package com.baturu.vin.honda.dal.dao;

import com.baturu.vin.honda.dto.HondaBtrPartsDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;
import java.util.Set;

/**
 * @Author: jiangxinlei
 * @Time: 2019-05-13 15:05
 **/
public interface HondaBtrPartsDAO {

    @Select({"<script>",
            "select distinct btr_parts_name btrPartsName, basic_parts_name basicPartsName, distinguishing_marks distinguishingMarks, suffix",
            "from honda_btr_parts_mapping",
            "where brand_name = #{brandName}",
            "and btr_parts_name in ",
            "<foreach item='item' collection='btrPartsName' index='index' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</script>"})
    Set<HondaBtrPartsDTO> queryBtrPartsNameByBrand(@Param("brandName") String brandName,
                                                   @Param("btrPartsName") Collection<String> btrPartsName);


    @Select({"<script>",
            "SELECT partsCode, btrPartsName, hasImg FROM honda_oil_parts_mapping",
            "WHERE btrPartsName IN ",
            "<foreach item='btrPartsName' collection='btrPartsNames' open='(' separator=',' close=')'>",
            "#{btrPartsName}",
            "</foreach>",
            "<if test='brandName!=null and brandName!=\"\"'>",
            "AND brand_name = #{brandName}",
            "</if>",
            "</script>"})
    List<HondaBtrPartsDTO> queryOilRelationByBtrPartsNames(@Param("btrPartsNames") Set<String> btrPartsNames,
                                                           @Param("brandName") String brandName);

    @Select({"<script>",
            "SELECT partsCode, btrPartsName, hasImg FROM honda_oil_parts_mapping",
            "WHERE partsCode IN ",
            "<foreach item='partsCode' collection='partsCodes' open='(' separator=',' close=')'>",
            "#{partsCode}",
            "</foreach>",
            "</script>"})
    List<HondaBtrPartsDTO> queryOilRelationByBtrPartsCodes(@Param("partsCodes") Set<String> partsCodes);

    @Select({"<script>",
            "SELECT  btr_parts_name  FROM honda_btr_parts_name_diy_car",
            "WHERE btr_parts_name IN ",
            "<foreach item='btr_parts_name' collection='btr_parts_names' open='(' separator=',' close=')'>",
            "#{btr_parts_name}",
            "</foreach>",
            "</script>"})
    List<String> queryDiyCarBtrPartsName(@Param("btr_parts_names") Collection<String> btrPartsNames);


    @Select({"<script>",
            "SELECT  vincode  FROM honda_diy_car",
            "WHERE btrid = #{btrid} ",
            "</script>"})
    List<String> queryDiyCarByBtrid(@Param("btrid") String btrid);



}
